.PHONY: pytest pre-commit unasync build-sync tests

help::
	@echo "Available commands"
	@echo "  help           -- (default) print this message"

tests: mypy pytest
help::
	@echo "  tests          -- run all tests for supabase package"

pytest:
	uv run --package supabase pytest --cov=./ --cov-report=xml --cov-report=html -vv
help::
	@echo "  pytest         -- run pytest on supabase package"

mypy:
	uv run --package supabase mypy src/supabase tests
help::
	@echo "  mypy           -- run mypy on supabase package"


unasync:
	uv run run-unasync.py
build-sync: unasync
	sed -i 's/asyncio.create_task(self.realtime.set_auth(access_token))//g' src/supabase/_sync/client.py
	sed -i 's/asynch/synch/g' src/supabase/_sync/auth_client.py
	sed -i 's/Async/Sync/g' src/supabase/_sync/auth_client.py
	sed -i 's/Async/Sync/g' src/supabase/_sync/client.py
	sed -i 's/create_async_client/create_client/g' tests/_sync/test_client.py
	sed -i 's/SyncClient/Client/gi' tests/_sync/test_client.py
	sed -i 's/SyncHTTPTransport/HTTPTransport/g' tests/_sync/test_client.py
	sed -i 's/SyncMock/Mock/g' tests/_sync/test_client.py
help::
	@echo "  build-sync     -- generate _sync from _async implementation"

clean:
	rm -rf htmlcov .pytest_cache .mypy_cache .ruff_cache
	rm -f .coverage coverage.xml
help::
	@echo "  clean          -- clean intermediary files generated by tests"

build:
	uv build --package supabase
help::
	@echo "  build          -- invoke uv build on supabase package"
